/*
 * time_wheel.h
 *
 *  Created on: 2015-5-15
 *      Author: likui
 */

#ifndef TIME_WHEEL_H_
#define TIME_WHEEL_H_

#include "tw_timer.h"
#include <stdlib.h>

#define SLOTS_N     10
#define SI          1

typedef struct time_wheel_t {
    tw_timer_t   *slots[SLOTS_N];
    int          cur_slot;
}time_wheel_t;

time_wheel_t* time_wheel_create();
void time_wheel_init(time_wheel_t *tw);
void time_wheel_destroy(time_wheel_t **tw);
tw_timer_t* time_wheel_add(time_wheel_t *tw, int timeout);
void time_wheel_del_timer(time_wheel_t *tw, tw_timer_t *timer);
void time_wheel_tick(time_wheel_t *tw);
void time_wheel_update_timer(time_wheel_t *tw, tw_timer_t *timer, int timeout);

#endif /* TIME_WHEEL_H_ */
